home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0398.dms / q0398.adf / DonsGenies / ForADPro / f8.adpro next >
Text File  |  1992-07-31  |  3KB  |  104 lines

  1. /* Program to use ADPro to resize all the pics in a directory and maybe also crop them and reduce the number of colours. They can be saved to another directory. */
  2.  
  3. trace n
  4.  
  5. options results
  6. address "ADPro"
  7. getdir '"Select source directory"'
  8. if rc=10 then exit
  9. directory = ADPro_Result
  10. getdir '"Select destination directory"'
  11. if rc=10 then exit
  12. outdirectory = ADPro_Result
  13.  
  14. address command
  15. "list >ram:filelist "directory" all quick"
  16. call open(input,"ram:filelist","r")
  17.  
  18. address "ADPro"
  19.  
  20. lformat "UNIVERSAL"
  21. sformat "IFF"
  22.  
  23. /* Use the current screen format and number of colours. */
  24. render_type
  25. colours = ADPro_result
  26. screen_type
  27. stype = ADPro_result
  28.  
  29. /* Here is where you ask the user for figures */
  30.  
  31. getnumber '"Top crop (pixels)"'
  32. topcrop = ADPro_result
  33. if rc~=0 then topcrop = 0
  34.  
  35. getnumber '"Left crop (pixels)"'
  36. leftcrop = ADPro_result
  37. if rc~=0 then leftcrop = 0
  38.  
  39. getnumber '"Right crop (pixels)"'
  40. rightcrop = ADPro_result
  41. if rc~=0 then rightcrop = 0
  42.  
  43. getnumber '"Bottom crop (pixels)"'
  44. bottomcrop = ADPro_result
  45. if rc~=0 then bottomcrop = 0
  46.  
  47. getnumber '"Output width (pixels)"' 320 16 1280
  48. if rc~=0 then do
  49.     okay1 "User aborted program"
  50.     exit
  51.     end
  52. width = ADPro_result
  53.  
  54. getnumber '"Output height (pixels)"' 256 16 1024
  55. if rc~=0 then do
  56.     okay1 "User aborted program"
  57.     exit
  58.     end
  59. height = ADPro_result
  60.  
  61.  
  62. do i = 1 to 100   /* safety limit of 100 files  */
  63.     filename = readln(input)
  64.     if filename = "" then break
  65.     if word(filename,2) = "files" then iterate /* This line not a file name */
  66.     if word(filename,1) = "TOTAL:" then break  /* or this one */
  67.  
  68.     if right(directory,1) = ":" then fullname = directory||filename
  69.     else fullname = directory||"/"||filename
  70.     load fullname
  71.     if rc ~=0 then iterate /* if load fails, try the next one */
  72.  
  73. /* Get size of loaded image, before scaling */
  74.     xsize
  75.     inputwidth = ADPro_result
  76.     ysize
  77.     inputheight = ADPro_result
  78.  
  79. /* Here is where all the image processing is done */
  80.     outwidth = inputwidth -leftcrop-rightcrop
  81.     if outwidth<16 then outwidth = inputwidth
  82.     outheight = inputheight -topcrop-bottomcrop
  83.     if outheight<16 then outheight = inputheight
  84.     operator "CROP_IMAGE" outwidth outheight leftcrop topcrop
  85.     abs_scale width height
  86.     render_type colours   /* number of colours  */
  87.     screen_type stype  /* PAL/NTSC, overscan, etc */
  88.     execute
  89.  
  90. /* Construct a name for the new file and save it  */
  91.     newname = outdirectory||"/"||filename||".proc"
  92.     save newname "IMAGE"
  93.     if rc~=0 then do
  94.         okay1 '"Trouble saving file "||newname'
  95.         exit
  96.         end
  97.     end
  98.  /* end of multiple files */
  99.  
  100.  
  101. exit
  102. end
  103.  
  104.